package main

import "fmt"

//	map[K]V, map[K1]map[K2]V
func main() {
	m := map[string]string{
		"name":    "lcl",
		"course":  "golang",
		"site":    "imooc",
		"quality": "notbad",
	}
	m2 := make(map[string]int) // m2 == empty map

	var m3 map[string]int // m3 == nil
	fmt.Println(m, m2, m3)

	fmt.Println("遍历map")
	for k, v := range m {
		fmt.Println(k, v)
	}

	fmt.Println("Getting values")
	courseName, ok := m["course"]
	fmt.Println(courseName, ok) //ok == true
	// 找一个不存在的key的时候
	causeName, ok := m["cause"]
	fmt.Println(causeName, ok) //ok == false

	fmt.Println("Delete values")
	name, ok := m["name"]
	fmt.Println(name, ok)

	delete(m, "name")
	name, ok = m["name"]
	fmt.Println(name, ok)
}
